//
// Created by jie.jiang on 2023/5/8.
//
#include "tabview.h"
#include "lvgl.h"

static lv_style_t style_title;
static lv_style_t style_text_muted;

static void profile_create(lv_obj_t *parent)
{
//  lv_obj_t *panel = lv_obj_create(parent);
//  lv_obj_set_height(panel,30);

  LV_IMG_DECLARE(pro);
  lv_obj_t *img_pro = lv_img_create(parent);
  lv_img_set_src(img_pro, &pro);
  lv_obj_set_pos(img_pro, 0,-10);

  lv_obj_t *dsc = lv_label_create(parent);
  lv_obj_set_pos(dsc, 70,15);
  lv_label_set_text(dsc, "Tab 1");
  lv_obj_add_style(dsc, &style_text_muted, 0);
  lv_label_set_long_mode(dsc, LV_LABEL_LONG_WRAP);
}
static void analytics_create(lv_obj_t *parent)
{
//  lv_obj_t *panel = lv_obj_create(parent);
//  lv_obj_set_height(panel,30);

  LV_IMG_DECLARE(avatar);
  lv_obj_t *img_pro = lv_img_create(parent);
  lv_img_set_src(img_pro, &avatar);
  lv_obj_set_pos(img_pro, 0,-10);

  lv_obj_t *dsc = lv_label_create(parent);
  lv_obj_set_pos(dsc, 70,15);
  lv_label_set_text(dsc, "Tab 2");
  lv_obj_add_style(dsc, &style_text_muted, 0);
  lv_label_set_long_mode(dsc, LV_LABEL_LONG_WRAP);
}
static void shop_create(lv_obj_t *parent)
{
//  lv_obj_t *panel = lv_obj_create(parent);
//  lv_obj_set_height(panel,30);

  LV_IMG_DECLARE(years);
  lv_obj_t *img_pro = lv_img_create(parent);
  lv_img_set_src(img_pro, &years);
  lv_obj_set_pos(img_pro, 0,-10);

  lv_obj_t *dsc = lv_label_create(parent);
  lv_obj_set_pos(dsc, 70,15);
  lv_label_set_text(dsc, "Tab 3");
  lv_obj_add_style(dsc, &style_text_muted, 0);
  lv_label_set_long_mode(dsc, LV_LABEL_LONG_WRAP);
}
lv_obj_t *tabview;
void lvg_tabview_create(void)
{
  lv_style_init(&style_title);
  lv_style_init(&style_text_muted);


  tabview = lv_tabview_create(lv_scr_act(),LV_DIR_TOP,20);
  lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Pro");
  lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Ana");
  lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Shop");

  profile_create(tab1);
  analytics_create(tab2);
  shop_create(tab3);
}

void tabview_changed(uint8_t page)
{
  lv_tabview_set_act(tabview,page,LV_ANIM_OFF);
}